/*
 *  Copyright 2010 SPeCS Research Group.
 * 
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 * 
 *       http://www.apache.org/licenses/LICENSE-2.0
 * 
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *  under the License.
 */

package org.specs.DymaLib.Mapping.Tables;

import java.util.HashMap;
import java.util.Map;

/**
 * Table with maps register definitions with PE elements.
 *
 * @author Joao Bispo
 */
public class RegisterTable {

   public RegisterTable() {
      registerTable = new HashMap<String, RtInfo>();
   }

   public void updateTable(String register, int cycle, int pePosition) {
      registerTable.put(register, new RtInfo(cycle, pePosition));
   }

   public Integer getCycle(String register) {
      RtInfo info = registerTable.get(register);
      if(info == null) {
         return null;
      }

      return info.cycle;
   }

   public Integer getPePosition(String register) {
      RtInfo info = registerTable.get(register);
      if(info == null) {
         return null;
      }

      return info.pePosition;
   }
   
   public Map<String, RtInfo> registerTable;

   public class RtInfo {

      public RtInfo(int cycle, int pePosition) {
         this.cycle = cycle;
         this.pePosition = pePosition;
      }

      //public static RtInfo newConstant(int constantValue);

      //boolean isConstant;
      int cycle;
      int pePosition;
      //boolean isSavedRegister;
   }
}
